package test13;
import java.lang.Cloneable;
public class Animal {
    public static void main(String[] args) {
        MyObject myObject = new MyObject("hhh",555);

        MyObject object = myObject.clone();

        System.out.println("Original: " + myObject);

        System.out.println("Cloned: " + object);
    }

}

class MyObject implements Cloneable{

    private String str;

    private int age;

    public MyObject(String str, int age) {
        this.age = age;

        this.str = str;
    }

    public String getStr() {
        return str;
    }

    public int getAge() {
        return age;
    }
    @Override
    public MyObject clone() {
        try {
            MyObject myObject = (MyObject) super.clone();
            return myObject;
        } catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }
    @Override
    public String toString() {
        return "{" +
                "value=" + age +
                ", name='" + str +
                '}';
    }

}
